SPB Git

Repository Public

page.tsx 6.9 KB 145 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : ORIX App Universe8 * File             : src/app/[locale]/maps/page.tsx9 * Module           : app10 * Repository       : https://git.spboucher.ai/orix-spboucher-ai11 * Project Website  : https://www.orixlab.dev12 * Created          : 2026-11-2513 * Last Modified    : 2026-11-2514 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: support@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243import type { Metadata } from "next";44import Link from "next/link";45import { getApp } from "@/lib/catalog";46import { mapLibrary, mapSize, type MapLicence, type MapRegion } from "@/lib/maps";47import { dict, fmtDate, href, isLocale, type Locale } from "@/lib/i18n";48import { alternates } from "@/lib/seo";4950export const revalidate = 300;5152export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }): Promise<Metadata> {53  const { locale } = await params; const t = dict(locale as Locale);54  return { title: t.maps.title, description: t.maps.lead, alternates: alternates("/maps", locale as Locale) };55}5657function Credits({ list }: { list: MapLicence[] }) {58  return (59    <>60      {list.map((l, i) => (61        <span key={`${l.source}|${l.licence}`}>62          {i > 0 ? " · " : ""}63          {l.url ? <a className="link" href={l.url} rel="noopener">{l.attribution}</a> : l.attribution}64          {l.licence ? <> (<span className="mono">{l.licence}</span>)</> : null}65        </span>66      ))}67    </>68  );69}7071function Row({ r, locale }: { r: MapRegion; locale: Locale }) {72  const t = dict(locale).maps;73  return (74    <li className="card p-6 sm:p-7" data-testid="map-region" data-region={r.id}>75      <div className="flex flex-wrap items-start justify-between gap-x-6 gap-y-3">76        <div className="min-w-0">77          <h2 className="h3">{r.names[locale]}</h2>78          <p className="mono mt-1 text-[0.85rem] text-ink3">{r.id}</p>79        </div>80        <ul className="inline-flex flex-wrap gap-1.5" aria-label={t.includes}>81          {r.capabilities.map((c) => <li key={c} className="tag">{t.capabilities[c]}</li>)}82        </ul>83      </div>84      <dl className="mt-5 grid grid-cols-2 gap-x-6 gap-y-4 text-[0.92rem] sm:grid-cols-4">85        <div><dt className="text-ink3">{t.cols.download}</dt><dd className="mono mt-0.5 font-semibold">{mapSize(r.downloadBytes, locale)}</dd></div>86        <div><dt className="text-ink3">{t.cols.installed}</dt><dd className="mono mt-0.5 font-semibold">{r.installedBytes ? mapSize(r.installedBytes, locale) : "–"}</dd></div>87        <div><dt className="text-ink3">{t.cols.data}</dt><dd className="mt-0.5 font-semibold">{r.dataDate ? <time dateTime={r.dataDate}>{fmtDate(r.dataDate, locale)}</time> : "–"}</dd></div>88        <div><dt className="text-ink3">{t.cols.version}</dt><dd className="mono mt-0.5 font-semibold">{r.dataVersion}</dd></div>89      </dl>90      <p className="mt-5 text-[0.85rem] text-ink3" data-testid="map-licences">91        {r.licences.length ? <Credits list={r.licences} /> : t.licencesMissing}92      </p>93    </li>94  );95}9697export default async function Maps({ params: p }: { params: Promise<{ locale: string }> }) {98  const { locale: raw } = await p; const locale: Locale = isLocale(raw) ? raw : "en";99  const all = dict(locale), t = all.maps, lib = await mapLibrary();100  const app = getApp("maps")?.app ?? null;101  return (102    <>103      <header className="relative isolate overflow-hidden pb-6 pt-32 sm:pt-44">104        <div className="aurora -z-10" aria-hidden /><div className="stars -z-10" aria-hidden /><div className="gridlines -z-10" aria-hidden />105        <div aria-hidden className="pointer-events-none absolute inset-x-0 bottom-0 -z-10 h-40 bg-gradient-to-b from-transparent to-bg" />106        <div className="wrap wrap-wide">107          <p className="eyebrow">{t.eyebrow}</p>108          <h1 className="display mt-6 max-w-5xl !text-[clamp(2.6rem,6.6vw,5.4rem)]">{t.title}</h1>109          <p className="lead mt-7">{t.lead}</p>110          {lib.regions.length > 0 && (111            <p className="mono mt-8 text-[0.85rem] text-ink3" data-testid="maps-summary">112              {t.summary(lib.regions.length)}113              {lib.updated ? ` · ${t.updated(fmtDate(lib.updated, locale))}` : ""}114            </p>115          )}116        </div>117      </header>118      <section className="wrap wrap-wide section !pt-12" aria-label={t.title}>119        {lib.regions.length === 0120          ? <p className="card p-10 text-center text-ink2" data-testid="maps-empty">{t.empty}</p>121          : <ul className="grid gap-5 lg:grid-cols-2" data-testid="map-regions">{lib.regions.map((r) => <Row key={r.id} r={r} locale={locale} />)}</ul>}122        <ol className="mt-20 grid gap-x-10 gap-y-8 md:grid-cols-3">123          {t.notes.map(([title, body], i) => (124            <li key={title} className="rule pt-6">125              <span className="mono beam-text text-[0.8rem] font-semibold tracking-[0.16em]">0{i + 1}</span>126              <h2 className="h3 mt-3">{title}</h2>127              <p className="mt-2 text-[0.96rem] text-ink2">{body}</p>128            </li>129          ))}130        </ol>131        <p className="mt-14 max-w-4xl text-[0.9rem] text-ink3" data-testid="maps-credit">132          {t.credit[0]}<a className="link" href="https://www.openstreetmap.org/copyright" rel="noopener">{t.credit[1]}</a>{t.credit[2]}133          <a className="link" href="https://git.spboucher.ai/orix-maps" rel="noopener">{t.credit[3]}</a>{t.credit[4]}134        </p>135        {app && (136          <p className="mt-6 text-[0.95rem] text-ink2" data-testid="maps-app">137            <Link className="link font-semibold text-ink" href={href(locale, "/apps/maps")}>{t.about(app.name)}</Link>138            <span className="tag ml-3 align-middle">{all.status[app.status]}</span>139          </p>140        )}141      </section>142    </>143  );144}145
Files main
Menu

Theme